package top.mengchaob.gitManage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import top.mengchaob.util.PropUtil;

import java.io.File;

/**
 * @title：
 * @author: mengchaob
 * @date: 2021年06月11日 21:54
 * @description:
 */
@Component
public class GitRunnerImpl implements ApplicationRunner {

    Logger logger = LoggerFactory.getLogger(GitRunnerImpl.class);
    @Override
    public void run(ApplicationArguments args) throws Exception {
        logger.debug("清理.git文件夹下的index.lock文件");
        String indexlock = PropUtil.getByKey("git.workSpace")+File.separator+".git"+File.separator+"index.lock";
        File file = new File(indexlock);
        if(file.exists()) {
            file.delete();
            System.out.println("删除成功");
        }
    }
}
